package router

import (
	"github.com/gin-gonic/gin"
	"github.com/kadycui/web/controller"
	"github.com/kadycui/web/middleware"
)

func Engine() *gin.Engine {
	// 生产环境
	// gin.SetMode(gin.ReleaseMode)
	gin.SetMode(gin.DebugMode)

	r := gin.Default()

	// 跨域
	r.Use(middleware.Cors())

	v1 := r.Group("/api/v1")

	{
		v1.GET("publish/ping", controller.Ping)
		v1.POST("publish/register", controller.PublishRegister)
		v1.POST("publish/login", controller.PublishLogin)
		v1.POST("publish/auth", controller.PublishAuth)
		v1.POST("publish/webhook", controller.Webhook)
	}

	return r
}
